<page-header [title]="'【' + entity.name + '】的信息'"></page-header>
<nz-card>
  <nz-tabset>
    <nz-tab [nzTitle]="'基本信息'">
      <nz-spin *ngIf="isLoading" class="modal-spin"></nz-spin>
      <form nz-form *ngIf="!isLoading" [formGroup]="validateForm" (ngSubmit)="submitForm()">
        <nz-form-item>
          <nz-form-label [nzSpan]="4" nzRequired nzFor="name">姓名</nz-form-label>
          <nz-form-control [nzSpan]="8" [nzValidateStatus]="validateForm.controls['name']">
            <input type="text" nz-input formControlName="name" placeholder="姓名">
            <nz-form-explain *ngIf="validateForm.get('name').dirty && validateForm.get('name').hasError('required')">请输入姓名</nz-form-explain>
            <nz-form-explain *ngIf="validateForm.get('name').dirty && validateForm.get('name').hasError('maxlength')">不能超过60个字</nz-form-explain>
          </nz-form-control>
          <nz-form-label [nzSpan]="4" nzRequired nzFor="phone">手机号</nz-form-label>
          <nz-form-control [nzSpan]="8" [nzValidateStatus]="validateForm.controls['phone']">
            <input type="text" nz-input formControlName="phone" placeholder="手机号,请注意手机号即为其初始密码">
            <nz-form-explain *ngIf="validateForm.get('phone').dirty && validateForm.get('phone').hasError('required')">请输入手机号</nz-form-explain>
            <nz-form-explain *ngIf="validateForm.get('phone').dirty && validateForm.get('phone').hasError('mobileValidate')">手机号码格式不正确</nz-form-explain>
          </nz-form-control>
        </nz-form-item>
        <nz-form-item>
          <nz-form-label [nzSpan]="4" nzFor="idNumber">身份证号</nz-form-label>
          <nz-form-control [nzSpan]="8" [nzValidateStatus]="validateForm.controls['idNumber']">
            <input type="text" nz-input formControlName="idNumber" placeholder="身份证号">
            <nz-form-explain *ngIf="validateForm.get('idNumber').dirty && validateForm.get('idNumber').hasError('required')">请输入身份证号</nz-form-explain>
          </nz-form-control>
          <nz-form-label [nzSpan]="4" nzFor="status">是否激活</nz-form-label>
          <nz-form-control [nzSpan]="8">
            <nz-form-text>{{entity.status|yesNoPipe}}</nz-form-text>
          </nz-form-control>
        </nz-form-item>
        <nz-form-item>
          <nz-form-label [nzSpan]="4" nzRequired nzFor="role">渠道级别</nz-form-label>
          <nz-form-control [nzSpan]="8" [nzValidateStatus]="validateForm.controls['levelId']">
            <nz-select formControlName="levelId" [nzPlaceHolder]="'渠道级别'" (ngModelChange)="filterParentOptions()" nzDisabled>
              <nz-option
                *ngFor="let option of levelOptions"
                [nzLabel]="option.name"
                [nzValue]="option.id">
              </nz-option>
            </nz-select>
            <nz-form-explain *ngIf="validateForm.get('levelId').dirty && validateForm.get('levelId').hasError('required')">请选择渠道级别</nz-form-explain>
          </nz-form-control>
          <nz-form-label [nzSpan]="4" nzFor="role">上级渠道</nz-form-label>
          <nz-form-control [nzSpan]="8" [nzValidateStatus]="validateForm.controls['parentId']">
            <nz-select formControlName="parentId" [nzPlaceHolder]="'上级渠道'" nzDisabled>
              <nz-option
                *ngFor="let option of parentsOptions"
                [nzLabel]="option.name"
                [nzValue]="option.id">
              </nz-option>
            </nz-select>
            <nz-form-explain *ngIf="validateForm.get('parentId').dirty && validateForm.get('parentId').hasError('required')">请选择上级渠道</nz-form-explain>
          </nz-form-control>
        </nz-form-item>
        <h2>普通账户</h2>
        <nz-form-item>
          <nz-form-label [nzSpan]="4">进货总额</nz-form-label>
          <nz-form-control [nzSpan]="8">
            <nz-form-text>{{entity.totalIn}}</nz-form-text>
          </nz-form-control>
          <nz-form-label [nzSpan]="4" >出货总额</nz-form-label>
          <nz-form-control [nzSpan]="8">
            <nz-form-text>{{entity.totalOut}}</nz-form-text>
          </nz-form-control>
        </nz-form-item>
        <nz-form-item>
          <nz-form-label [nzSpan]="4">零售总额</nz-form-label>
          <nz-form-control [nzSpan]="8">
            <nz-form-text>{{entity.totalSell}}</nz-form-text>
          </nz-form-control>
          <nz-form-label [nzSpan]="4" >当前余额</nz-form-label>
          <nz-form-control [nzSpan]="8">
            <nz-form-text>{{entity.balance}}</nz-form-text>
          </nz-form-control>
        </nz-form-item>
        <h2>零售账户</h2>
        <nz-form-item>
          <nz-form-label [nzSpan]="4">进货总额</nz-form-label>
          <nz-form-control [nzSpan]="8">
            <nz-form-text>{{entity.retailTotalIn}}</nz-form-text>
          </nz-form-control>
          <nz-form-label [nzSpan]="4" >出货总额</nz-form-label>
          <nz-form-control [nzSpan]="8">
            <nz-form-text>{{entity.retailTotalOut}}</nz-form-text>
          </nz-form-control>
        </nz-form-item>
        <nz-form-item>
          <nz-form-label [nzSpan]="4">零售总额</nz-form-label>
          <nz-form-control [nzSpan]="8">
            <nz-form-text>{{entity.retailTotalSell}}</nz-form-text>
          </nz-form-control>
          <nz-form-label [nzSpan]="4" >当前余额</nz-form-label>
          <nz-form-control [nzSpan]="8">
            <nz-form-text>{{entity.retailBalance}}</nz-form-text>
          </nz-form-control>
        </nz-form-item>
        <div nz-form-item nz-row  style="text-align: center;">
          <button nz-button type="button" (click)="goBack()">返回列表</button>
          <button nz-button type="submit" [nzType]="'primary'" >保存</button>
        </div>
      </form>
    </nz-tab>
    <nz-tab [nzTitle]="'下级代理商'">
      <agent-child [parentId]="id" [levelOptions]="levelOptions" #child></agent-child>
    </nz-tab>
    <nz-tab [nzTitle]="'渠道订单'">
      <app-order-list [agentId]="id" ></app-order-list>
    </nz-tab>
    <nz-tab [nzTitle]="'普通账户明细'">
      <app-agent-finance [agentId]="id" [financeType]="1"></app-agent-finance>
    </nz-tab>
    <nz-tab [nzTitle]="'零售账户明细'">
      <app-agent-finance [agentId]="id" [financeType]="2"></app-agent-finance>
    </nz-tab>
  </nz-tabset>
</nz-card>
